<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sb" uri="/struts-bootstrap-tags"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加用户</title>
<script type="text/javascript">
function checkName(){
	var subId=$("#subId").val();
	var subName=$("#subName").val();
	if(subName==null||subName==""){
		 $("#nameError").text("小类名称不能为空");
		}
	$.ajax({
		type:'get',
		url:'subType_checkName',
		data:{subId:subId,subName:subName},
		dataType:'json',
		 success: function(data){
            //alert(data.msg);
	            $("#nameError").text(data[0].msg);
			 }
		});
}
</script>
</head>
<body>
<s:form action="subType_saveSubType" method="post" theme="simple" id="save">
  <s:hidden name="subType.subId"  value='%{subType.subId}' id="subId"></s:hidden>
  <s:hidden name="subType.created"  value='%{subType.created}'></s:hidden>
  <s:hidden name="subType.createId"  value='%{subType.createId}'></s:hidden>
  <s:hidden name="supId" value="%{supId}" id="supId"></s:hidden>
<table>
<tr>
<td style="width: 110px;">所属大类:</td>
<td> 
<s:select id="supName" name="supTypeId" label="所属大类" list="supTypes" listKey="supId" listValue="supName"></s:select>
</td>
<td></td>
</tr>
<tr>
<td style="width: 110px;">大类名称:</td>
<td>
<s:textfield name="subType.subName" required="true"  id="subName"  placeholder="请输入大类名称" value="%{subType.subName}"></s:textfield>
</td>
<td id="nameError" ></td>
</tr>
</table>
<script type="text/javascript">
var supId=$("#supId").val();
$("#supName option[value="+supId+"]").attr("selected",true);
</script>
</s:form>
</body>
</html>